﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

using EnterpriseDT.Net.Ftp;

namespace FreeboxHDVideoPlayer
{
    public class DeleteVideoWorker : AbstractWorker
    {
        public string Video
        {
            set;
            get;
        }

        public DeleteVideoWorker(string host, int port, string user, string password)
            : base(host, port, user, password)
        {
        }

        protected override void OnDoWork(DoWorkEventArgs e)
        {
            ReportProgress(0, "Connection au serveur...");
            using (FreeBoxHDFTP ftp = new FreeBoxHDFTP(this.Host, this.Port, this.User, this.Password))
            {
                ftp.Connect();
                ftp.Login();
                ftp.GotoVideoHome();
                ReportProgress(0, "Suppression de " + Video);
                ftp.Delete(Video);
            }
            if (VideoLocalCache.Exists(Video))
            {
                ReportProgress(0, "Suppression de " + VideoLocalCache.GetLocalPath(Video));
                VideoLocalCache.Delete(Video);
            }
        }
    }
}
